﻿using Magicodes.ExporterAndImporter.Excel.AspNetCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.MaterialMasterData.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.ObjectMapping;

namespace NP.BPMReportPlatform.MaterialMasterData
{
    /// <summary>
    /// 物料主数据流程 接口
    /// </summary>
    [Authorize]
    [ApiController]
    [Route("api/mmd")]
    public class LCZXCPGJController : BPMReportPlatformController
    {
        private readonly ILCZXCPGJService _lCZXCPGJService;
        public LCZXCPGJController(ILCZXCPGJService lCZXCPGJService) 
        {
            _lCZXCPGJService = lCZXCPGJService;
        }

        /// <summary>
        ///立才中心产品改价流程报表 查询
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("LCZXCPGJ/GetAllAsync")]
        public async Task<PagedResultDto<LCZXCPGJOutput>> GetAllAsync([FromBody] LCZXCPGJInput input)
        {
            return await _lCZXCPGJService.GetAllAsync(input);
        }

        /// <summary>
        /// 立才中心产品改价流程报表 导出数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("LCZXCPGJ/ExportAsync")]
        public async Task<XlsxFileResult<LCZXCPGJOutput>> ExportAsync([FromBody] LCZXCPGJInput input)
        {
            var rst = await _lCZXCPGJService.ExportAsync(input);
            var result = new List<LCZXCPGJOutput>();
            return new XlsxFileResult<LCZXCPGJOutput>(ObjectMapper.Map(rst, result), "导出Excel");
        }
    }
}
